package com.example.mybatisplus.service;

import com.example.mybatisplus.entity.User;
import com.example.mybatisplus.entity.UserRole;
import com.example.mybatisplus.entity.role;
import com.example.mybatisplus.entity.userRolePrower;
import com.example.mybatisplus.mapper.RoleMapper;
import com.example.mybatisplus.mapper.UserMapper;
import com.example.mybatisplus.mapper.UserRoleMapper;
import com.example.mybatisplus.mapper.prowerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 * User: lixiao
 * Created Date: 2020/9/16 10:35
 */
@Service
public class Userservice {

    @Autowired
    UserMapper userMapper;

    @Autowired
    UserRoleMapper userRoleMapper;

    @Autowired
    RoleMapper roleMapper;

    @Autowired
    prowerMapper prowerMapper;

    @Transactional
    public String add(){
        User user=new User();
        user.setName("mybatis=plus");
        user.setOid(UUID.randomUUID().toString());
        user.setRole("121");
        userMapper.insert(user);
        role role=new role();
        role.setOid(UUID.randomUUID().toString());
        role.setPrower_oid("12122121");
        role.setRole_name("tranaction");
        roleMapper.insert(role);
        return  user.getOid();


    }

    public List<UserRole> gerUserRole(){
        return userRoleMapper.getUserRole();
    }

    public List<userRolePrower> getuserRolePrower(){
        return prowerMapper.query();
    }

}